Skip to content

fix: count unsupported operators with side effects - #4703

Merged
lanluo-nvidia merged 1 commit into
pytorch:mainfrom
shoumikhin:upstream/full-support-ignores-impure-refusals
Sep 30, 2026
Merged

lanluo-nvidia merged 1 commit into
pytorch:mainfrom
shoumikhin:upstream/full-support-ignores-impure-refusals

Conversation

@shoumikhin

@shoumikhin shoumikhin commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem

require_full_compilation=True is meant to fail compilation if any operator has to run in PyTorch instead of TensorRT. It did not fail for operators with side effects, such as random number generators or in-place updates, when those operators had no TensorRT converter. The model compiled anyway, with the operator silently left in PyTorch.

The reason is how full support was decided. The check only looked at the record of unsupported operators, and that record excludes operators with side effects on purpose. So a refused random operator was invisible to the check.

Change

Recent work added a separate record of every operator that falls back to PyTorch, including the ones with side effects. This change uses that record: a model counts as fully supported only when both the unsupported record and the fallback record are empty. It is applied in the fast, global, and hierarchical partitioners. The hierarchical partitioner did not keep a fallback record, so this adds one.

The unsupported record itself is left exactly as it was, so the fallback reporting that depends on it keeps working unchanged. A refused random operator now makes require_full_compilation=True raise, while a dry run still reports the fallback without raising.

Tests

Updated the full-support detection test to the new mechanism: a refused impure operator makes require_full_compilation raise and is recorded in the fallback record, while the unsupported record stays empty for it. A fully supported model is still accepted, and a refused pure operator is still rejected. Tests were run on Linux x86_64 with the standard build; they exercise the three partitioners' support classes. TensorRT-RTX, Windows, and aarch64 were not rerun.

@meta-cla meta-cla Bot added the cla signed label Sep 10, 2026
@github-actions github-actions Bot added component: tests Issues re: Tests component: core Issues re: The core compiler component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Sep 10, 2026
@github-actions
github-actions Bot requested a review from narendasan September 10, 2026 04:06
@shoumikhin
shoumikhin force-pushed the upstream/full-support-ignores-impure-refusals branch from 8f13b84 to 23ae50b Compare September 12, 2026 04:58
@shoumikhin
shoumikhin force-pushed the upstream/full-support-ignores-impure-refusals branch 3 times, most recently from d949794 to ab85078 Compare September 30, 2026 01:27
…yTorch

require_full_compilation=True is meant to fail if any operator has to run in PyTorch.
It did not fail for operators with side effects, such as random or in-place ops,
because the full-support check only looked at unsupported_operators, and that
dictionary excludes impure operators on purpose.

Recent work added a separate fallback_operators record that does include impure
refusals. Use it: a model is fully supported only when both unsupported_operators and
fallback_operators are empty. This is applied in the fast, global, and hierarchical
partitioners. The hierarchical partitioner did not have a fallback record, so add one.

unsupported_operators is left exactly as it was, so the fallback reporting that relies
on it keeps working unchanged. A refused random operator now makes
require_full_compilation raise, while a dry run still reports without raising.
@shoumikhin
shoumikhin force-pushed the upstream/full-support-ignores-impure-refusals branch from ab85078 to a1ec9cc Compare September 30, 2026 02:28

@lanluo-nvidia lanluo-nvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@lanluo-nvidia
lanluo-nvidia merged commit 612437a into pytorch:main Sep 30, 2026
53 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed component: api [Python] Issues re: Python API component: core Issues re: The core compiler component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: tests Issues re: Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants